package server.core;

import lombok.Data;
import org.dom4j.Node;

import java.util.ArrayList;
import java.util.List;

@Data
public class ServiceMapper {
    private Connector connector;
    private List<Host> hostList;
    private Engine engine;

    public ServiceMapper(Node serviceNode) {
        Node connectorNode = serviceNode.selectSingleNode("//connector");
        connector = new Connector(connectorNode);
        List<Node> list = serviceNode.selectNodes("//host");
        hostList = new ArrayList<>();
        for (Node node : list) {
            hostList.add(new Host(node));
        }

        engine = new Engine();
        engine.init(this);
    }
    public void start() {
        engine.start();
    }
}
